//index.js
//获取应用实例
const app = getApp()

Page({
    data: {
        message: {
            time: (new Date()).valueOf(),
            msg: "这里是woodpecker-miniprogram " + (new Date()).valueOf()
        }

    },
    onShow: function () {
        let that = this;
        let newDate = {
            a: JSON.stringify([{a: 1, b: 2}, {a: 3, b: 2}])
        }
        wx.request({
            url: 'https://www.zhanghuajun.top/woodpecker/',
            method: 'POST',
            data: {
                message: newDate.a
            },
            header: {
                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
            },
            success(res) {
                console.log(res)
            }
        });
        wx.getSystemInfoAsync({
            success(res) {
                that.setData({
                    message: res
                })
            }
        })

    }, bindtest: function () {
        let that = this;
        wx.request({
            url: 'https://www.zhanghuajun.top/woodpecker/',
            data: {
                message: that.data.message
            },
            method: 'GET',
            header: {
                'content-type': 'application/json' // 默认值
            },
            success: function (res) {
                console.log(res.data);
                that.setData({
                    returnMsg: res.data
                })
            },
            fail: function (res) {
                console.log(".....fail.....");
            }
        })
    },
})